using UnityEngine;
using System.Collections;

/// \class  gkPlayerDeathNotifierOnDestruction
/// \brief  Notify the game of the player destruction
[AddComponentMenu("GK/Engine/Game/Player/Death/gkPlayerDeathNotifierOnDestruction")]
public class gkPlayerDeathNotifierOnDestruction : MonoBehaviour 
{	
	/// \brief Called when the component is disabled
	void OnDestroy() 
	{
		GameObject rGame;
		
		// Try to get the game
		rGame = GameObject.Find("Game");
			
		// Notify the game that the player is dead
		if(rGame != null)
		{
			rGame.GetComponent<gkEventComponent>().RaiseEvent(gkPlayerEvent.PlayerDeath);
		}
	}
}